package com.brooks.demo;

import java.util.concurrent.TimeUnit;

/**
 * 锁的可重入
 *
 * @Author mihutu
 * @Date 2020/10/16 15:12
 * @Version 1.0
 */
public class DemoThread7 {
    synchronized void m1() throws InterruptedException {
        System.out.println("m1 start...");
        TimeUnit.SECONDS.sleep(1);
        m2();
        System.out.println("m1 end...");
    }
    synchronized void m2() throws InterruptedException {
        System.out.println("m2 start");
        TimeUnit.SECONDS.sleep(2);
        System.out.println("m2 end");
    }

    public static void main(String[] args) throws InterruptedException {
        new DemoThread7().m1();
    }
}